﻿namespace System.ServiceModel.DomainServices.Client
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.ComponentModel.DataAnnotations;

    public class QueryCompletedResult
    {
        private ReadOnlyCollection<Entity> _entities;
        private ReadOnlyCollection<Entity> _includedEntities;
        private int _totalCount;
        private ReadOnlyCollection<ValidationResult> _validationErrors;

        public QueryCompletedResult(IEnumerable<Entity> entities, IEnumerable<Entity> includedEntities, int totalCount, IEnumerable<ValidationResult> validationErrors)
        {
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }
            if (includedEntities == null)
            {
                throw new ArgumentNullException("includedEntities");
            }
            if (validationErrors == null)
            {
                throw new ArgumentNullException("validationErrors");
            }
            this._entities = entities.ToList<Entity>().AsReadOnly();
            this._includedEntities = includedEntities.ToList<Entity>().AsReadOnly();
            this._totalCount = totalCount;
            this._validationErrors = validationErrors.ToList<ValidationResult>().AsReadOnly();
        }

        public IEnumerable<Entity> Entities
        {
            get
            {
                return this._entities;
            }
        }

        public IEnumerable<Entity> IncludedEntities
        {
            get
            {
                return this._includedEntities;
            }
        }

        public int TotalCount
        {
            get
            {
                return this._totalCount;
            }
        }

        public IEnumerable<ValidationResult> ValidationErrors
        {
            get
            {
                return this._validationErrors;
            }
        }
    }
}

